//
//  HYFVisitController.swift
//  MyWeibo
//
//  Created by 黄勇锋 on 16/7/19.
//  Copyright © 2016年 黄勇锋. All rights reserved.
//

import UIKit

class HYFVisitController: UIViewController {
    
    //声明一个 view 属性
    var visitorView:HYFVisitorView?
    
    //声明一个 bool 属性
    var isLogin:Bool = HYFUserAccountViewModel.sharedTools.isLogin
    
    //懒加载 一个 tableView
    var tableView:UITableView = UITableView()
    
    override func loadView() {
        
        //如果登陆了,显示tabelView ,如果没有登陆,那么显示游客界面
        isLogin ?(view = tableView):setupVisitorView()
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    func setupVisitorView(){
        
        visitorView = HYFVisitorView()
        view = visitorView
        
        //设置导航栏两边的按钮  ---> 防止循环引用
        visitorView?.closure = {[weak self] in
            
            self?.loginClick()
        }
        
        setupNav()
    }
    
    func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HYFVisitController.loginClick))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HYFVisitController.loginClick))
        
    }
    
    @objc  private func loginClick(){
        
        //跳转控制器
        presentViewController(UINavigationController(rootViewController:HYFAuthController()), animated: true, completion: nil)
    }
    
    
    func setupUI(){
        
        
        
    }
    


}
